package edu.scut.course_management.po;

/**
 * 持久化对象：学生和某门具体课程的关联
 * @author thompson
 */
public class Takes {
    private String studentId;
    private Integer periodId;
    private String year;
    private String term;
    private Integer courseId;
    private String buildingId;
    private String roomNumber;

    
    
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public Integer getPeriodId() {
        return periodId;
    }

    public void setPeriodId(Integer periodId) {
        this.periodId = periodId;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getTerm() {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    public Integer getCourseId() {
        return courseId;
    }

    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    public String getBuildingId() {
        return buildingId;
    }

    public void setBuildingId(String buildingId) {
        this.buildingId = buildingId;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public void setRoomNumber(String roomNumber) {
        this.roomNumber = roomNumber;
    }

    @Override
    public String toString() {
        return "Takes {" + 
            "buildingId=" + buildingId + 
            ", courseId=" + courseId + 
            ", periodId=" + periodId + 
            ", roomNumber=" + roomNumber + 
            ", studentId=" + studentId + 
            ", term=" + term + 
            ", year=" + year + 
            "}";
    }

    @Override
    public boolean equals(Object obj){
        if(!(obj instanceof Takes)){
            return false;
        }
        else{
            return studentId.equals(((Takes)obj).getStudentId())&&
                   periodId.equals(((Takes)obj).getPeriodId())&&
                   year.equals(((Takes)obj).getYear())&&
                   term.equals(((Takes)obj).getTerm())&&
                   courseId.equals(((Takes)obj).getCourseId())&&
                   buildingId.equals(((Takes)obj).getBuildingId())&&
                   roomNumber.equals(((Takes)obj).getRoomNumber());
        }
    }

    public Takes(String studentId, Integer periodId, String year, String term, Integer courseId, String buildingId,
            String roomNumber) {
        this.studentId = studentId;
        this.periodId = periodId;
        this.year = year;
        this.term = term;
        this.courseId = courseId;
        this.buildingId = buildingId;
        this.roomNumber = roomNumber;
    }

    public Takes(String studentId, Section section){
        this.studentId = studentId;
        this.periodId = section.getPeriodId();
        this.year = section.getYear();
        this.term = section.getTerm();
        this.courseId = section.getCourseId();
        this.buildingId = section.getBuildingId();
        this.roomNumber = section.getRoomNumber();
    }

    
}